************************************Add Control Variables********************
clear all

use "$folder/data/input/aej_data_state.dta", clear

keep year state cpi ideociti income fcapout_sl froadscap_sl totexp froads f2roads froadscap fcapout igexp figexp direxp income2 f2publicsafety f2admin f2natres f2hospital f2alleduc f2welf urban foreign kids aged lpop lpop2 ltotemp lfullemp lpartemp ltotpay lftequpay figexp_noeduc f2other fedigPexp

keep if year>=1964


collapse (mean) cpi ideociti income fcapout_sl froadscap_sl totexp froads f2roads froadscap fcapout igexp figexp direxp income2 f2publicsafety f2admin f2natres f2hospital f2alleduc f2welf urban foreign kids aged lpop lpop2 ltotemp lfullemp lpartemp ltotpay lftequpay figexp_noeduc f2other fedigPexp, by(state year)


sort state year

foreach x in  cpi ideociti income fcapout_sl froadscap_sl totexp froads f2roads froadscap fcapout igexp figexp direxp income2 f2publicsafety f2admin f2natres f2hospital f2alleduc f2welf urban foreign kids aged lpop lpop2 ltotemp lfullemp lpartemp ltotpay lftequpay figexp_noeduc f2other fedigPexp {


bys state : gen initial1_`x' = `x'[1] 
bys state : gen initial2_`x' = `x'[2] 
bys state : gen initial_`x' = (initial1_`x' + initial2_`x')/2


}
rename state statenumb
keep if year==1964
drop year
save data_control, replace